emojis
✨ Lookup and iterate over emoji names, shortcodes, and groups.
Features
- Lookup up emoji by Unicode value
- Lookup up emoji by GitHub shortcode (gemoji v4.1.0)
- Iterate over emojis in recommended order
- Iterate over emojis in an emoji group, e.g. “Smileys & Emotion” or “Flags”
- Iterate over the skin tones for an emoji
- Uses Unicode v15.0 emoji specification
Getting started
First, add the emojis
crate to your Cargo manifest.
Simply use the get()
function to lookup emojis by Unicode value.
let rocket = get.unwrap;
Or the get_by_shortcode()
function to lookup emojis by gemoji shortcode.
let rocket = get_by_shortcode.unwrap;
These operations take Ο(1) time.
MSRV
Currently the minimum supported Rust version is 1.60 due to the dependency
on phf
. The policy of this crate is to only increase the MSRV in a
breaking release.
Examples
The returned Emoji
struct has various information about the emoji.
let hand = get.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Another common operation is iterating over the skin tones of an emoji.
let raised_hands = get.unwrap;
let skin_tones: = raised_hands.skin_tones.unwrap.map.collect;
assert_eq!;
You can use the iter()
function to iterate over all emojis (only
includes the default skin tone versions).
let smiley = iter.next.unwrap;
assert_eq!;
It is recommended to filter the list by the maximum Unicode version that you wish to support.
let iter = iter.filter;
Using the Group
enum you can iterate over all emojis in a group.
let grapes = FoodAndDrink.emojis.next.unwrap;
assert_eq!;
See examples/replace.rs for an example that replaces gemoji names in text.
|
License
This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.